package com.ledi.guns.modular.ledipay.controller;

import io.swagger.annotations.Api;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.plugins.Page;
import com.ledi.guns.common.annotion.Permission;
import com.ledi.guns.common.persistence.model.vo.DayOrHourChargeCountVo;
import com.ledi.guns.common.persistence.model.vo.EveryDayCountVo;
import com.ledi.guns.common.persistence.model.vo.EveryFlowCountVo;
import com.ledi.guns.common.persistence.model.vo.EveryMonthSmsCountVo;
import com.ledi.guns.common.persistence.model.vo.HotSchoolVo;
import com.ledi.guns.common.persistence.model.vo.SchoolInfoVo;
import com.ledi.guns.core.base.tips.SuccessTip;
import com.ledi.guns.core.base.tips.Tip;
import com.ledi.guns.modular.ledipay.controller.req.agent.QueryHotData;
import com.ledi.guns.modular.ledipay.controller.req.agent.QuerySmsData;
import com.ledi.guns.modular.ledipay.controller.req.school.AddSchoolInfo;
import com.ledi.guns.modular.ledipay.controller.req.school.AddSchoolPayItem;
import com.ledi.guns.modular.ledipay.controller.req.school.EditAccount;
import com.ledi.guns.modular.ledipay.controller.req.school.EditSchoolInfo;
import com.ledi.guns.modular.ledipay.controller.req.school.QuerySchoolInfo;
import com.ledi.guns.modular.ledipay.controller.req.school.QuerySeeSchoolInfo;
import com.ledi.guns.modular.ledipay.service.impl.SchoolServiceImpl;

/**
 * 学校管理控制器
 *
 * @author fengshuonan
 * @Date 2017-11-29 09:30:10
 */
@Api
@RestController
@RequestMapping("/school")
public class SchoolController {

	@Autowired
	private SchoolServiceImpl schoolService;

	/**
	 * @api {POST} /school/list 学校列表
	 * @apiGroup school
	 * @apiName list
	 * @apiParam {string} orderBy 排序
	 * @apiParam {string} orderType 排序类型
	 * @apiParam {String} schoolName 学校名称
	 * @apiParam {String} schoolContactPeople 联系人
	 * @apiParam {String} contactTel 联系方式
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiParam {Long} agentId 当前用户ID
	 * @apiParam {String} belongAgentName 所属代理商名称
	 * @apiParam {int} provinceCode 省
	 * @apiParam {int} cityCode 市
	 * @apiParam {int} districtCode 区
	 * @apiParam {String} freeMonth 赠送月份
	 * @apiSuccess {String} agentName 代理商名称
	 * @apiSuccess {int} studentContribution 学生缴费人数
	 * @apiSuccess {Long} giveCount 每月赠送短信额度（新增）
	 * @apiSuccess {Long} smsCount 短信使用总量（新增）
	 * @apiSuccess {String} freeMonth 赠送月份（新增）
	 * @apiSuccess {bigDecimal} flow 总流水
	 * @apiSuccess {bigDecimal} aliFlow 支付宝流水（新增）
	 * @apiSuccess {bigDecimal} weixinFlow 微信流水（新增）
	 * @apiSuccess {Date} createTime 开通时间
	 * @apiSuccess {String} schoolName 学校名称
	 * @apiSuccess {String} provinceName 省
	 * @apiSuccess {String} cityName 市
	 * @apiSuccess {String} districtName 区
	 * @apiSuccess {String} schoolContactPeople 联系人
	 * @apiSuccess {String} contactTel 联系方式
	 * @apiSuccess {Integer} versionNo 版本号
	 * @apiVersion 1.2.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "id": "XX",
	 *                  "schoolContactPeople":"张三"
	 *                  "startTime":"2017-11-20 16:54:32"
	 *                  "endTime":"2017-12-20 16:54:32"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "count": 8,
	 *                    "firstResult": 0,
	 *                    "list": [
	 *                    {
	 *                    "agentName": "金华代理商",
	 *                    "belongAgent": "",
	 *                    "cityName": "市辖区",
	 *                    "contactTel": "15695280021",
	 *                    "createTime": "2017-12-18 18:41:46",
	 *                    "districtName": "东城区",
	 *                    "flow": 0,
	 *                    "id": 44,
	 *                    "provinceName": "北京市",
	 *                    "schoolContactPeople": "二恶烷热无",
	 *                    "schoolName": "辅导费",
	 *                    "studentContribution": 0,
	 *                    "versionNo": 1
	 *                    }
	 *                    ],
	 *                    "orderBy": "id",
	 *                    "orderType": "DESC",
	 *                    "pageNo": 1,
	 *                    "pageSize": 10,
	 *                    "search": {
	 *                    "orderType": "DESC",
	 *                    "agentId": "",
	 *                    "defaultPageSize": 10,
	 *                    "pageSize": 10,
	 *                    "orderBy": "id",
	 *                    "firstResult": 0,
	 *                    "contactTel": "",
	 *                    "pageNo": 1,
	 *                    "schoolContactPeople": "",
	 *                    "belongAgentName": "金华代理商",
	 *                    "startTime": "",
	 *                    "endTime": "",
	 *                    "schoolName": ""
	 *                    },
	 *                    "total": 8
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/list", method = RequestMethod.POST)
	public Tip getSchoolInfoList(@RequestBody QuerySchoolInfo querySchoolInfo) {

		querySchoolInfo.checkOrder(SchoolInfoVo.class);
		Page<SchoolInfoVo> page = schoolService.getSchoolInfoList(new Page<SchoolInfoVo>(querySchoolInfo.getPageNo(), querySchoolInfo.getPageSize()), querySchoolInfo);
		return SuccessTip.buildSuccess(page);
	}

	/**
	 * @api {POST} /school/add 增加学校
	 * @apiGroup school
	 * @apiName add
	 * @apiParam {Byte} schoolNature 学校性质(1:公立学校 2:私立学校)
	 * @apiParam {Byte} schoolType 学校类型（1：托儿所 2：幼儿园 3:小学 4:初中 5:高中 6:其他（职高））
	 * @apiParam {String} schoolName 学校名称
	 * @apiParam {String} provinceCode 省
	 * @apiParam {Date} cityCode 市
	 * @apiParam {Date} districtCode 区
	 * @apiParam {Long} detailAddr 详细地址
	 * @apiParam {String} alipayPid PID号
	 * @apiParam {String} schoolContactPeople 联系人
	 * @apiParam {String} contactTel 电话号码
	 * @apiParam {String} belongAgentName 所属代理商
	 * @apiParam {String} loginPasswd 登陆密码
	 * @apiParam {String} subMchId 学校微信商户号ID
	 * @apiParam {String} alipayNumber 学校对公支付宝账号
	 * @apiParam {String} mailBox 学校对公邮箱
	 * @apiVersion 1.2.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "alipayPid": "string",
	 *                  "belongAgentName": "string",
	 *                  "cityCode": "string",
	 *                  "contactTel": "string",
	 *                  "detailAddr": "string",
	 *                  "districtCode": "string",
	 *                  "loginPasswd": "string",
	 *                  "provinceCode": "string",
	 *                  "schoolContactPeople": "string",
	 *                  "schoolName": "string",
	 *                  "schoolType": 2
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/add", method = RequestMethod.POST)
	public Tip addSchoolInfo(@RequestBody AddSchoolInfo addSchoolInfo) {

		schoolService.addSchoolInfo(addSchoolInfo);
		schoolService.sendMail(addSchoolInfo.getMailBox(), addSchoolInfo.getContactTel(), addSchoolInfo.getSchoolName(), addSchoolInfo.getLoginPasswd(),
				addSchoolInfo.getAlipayNumber());
		return SuccessTip.buildSuccess();
	}

	@Permission
	@RequestMapping(value = "/editAccount", method = RequestMethod.POST)
	public Tip editAccount(@RequestBody EditAccount editAccount) {

		schoolService.editAccount(editAccount);
		return SuccessTip.buildSuccess();
	}

	@Permission
	@RequestMapping(value = "/getAccount", method = RequestMethod.POST)
	public Tip editAccount(@RequestBody Long schoolId) {

		schoolService.getAccount(schoolId);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {POST} /school/getHotSchoolData 获取热门学校数据(TOP10)
	 * @apiGroup school
	 * @apiName getHotSchoolData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {String} belongAgent 所属代理商
	 * @apiSuccess {String} provinceName 省
	 * @apiSuccess {String} cityName 市
	 * @apiSuccess {String} districtName 区
	 * @apiSuccess {bigDecimal} chargeAmount 总流水
	 * @apiSuccess {bigDecimal} aliChargeAmount 支付宝流水
	 * @apiSuccess {bigDecimal} weixinChargeAmount 微信流水
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11 14:42:18",
	 *                  "endTime":"2017-12-11 14:42:18"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "belongAgent": "苏州地区代理商",
	 *                    "chargeAmount": 100,
	 *                    "cityName": "",
	 *                    "districtName": "",
	 *                    "provinceName": "",
	 *                    "schoolName": "金太阳幼儿园",
	 *                    "tollCollection": 3
	 *                    },
	 *                    {
	 *                    "belongAgent": "静冈代理商",
	 *                    "chargeAmount": 97.03,
	 *                    "cityName": "",
	 *                    "districtName": "",
	 *                    "provinceName": "",
	 *                    "schoolName": "小红幼儿园",
	 *                    "tollCollection": 2
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getHotSchoolData", method = RequestMethod.POST)
	public Tip getHotSchoolData(@RequestBody QueryHotData queryHotData) {

		Date startTime = queryHotData.getStartTime();
		Date endTime = queryHotData.getEndTime();
		Long agentId = queryHotData.getAgentId();
		List<HotSchoolVo> hotSchoolVos = schoolService.getHotSchoolData(startTime, endTime, agentId);
		return SuccessTip.buildSuccess(hotSchoolVos);
	}

	/**
	 * @api {POST} /school/getSchoolAndFlowData 获取学校和流水情况
	 * @apiGroup school
	 * @apiName getSchoolAndFlowData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11 14:42:18",
	 *                  "endTime":"2017-12-11 14:42:18"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "flow": 197.03,
	 *                    "newSchoolCount": 2
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getSchoolAndFlowData", method = RequestMethod.POST)
	public Tip getSchoolAndFlowData(@RequestBody QueryHotData queryHotData) {

		return SuccessTip.buildSuccess(schoolService.getSchoolAndFlowData(queryHotData));
	}

	/**
	 * @api {POST} /school/getSchoolCountData 获取学校统计数据(新增缴费学校数量)
	 * @apiGroup school
	 * @apiName getSchoolCountData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {String} currentSchoolData 新增学校
	 * @apiSuccess {String} totalSchoolData 总学校
	 * @apiSuccess {String} day 日期
	 * @apiSuccess {String} paySchoolData 缴费学校数量
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11",
	 *                  "endTime":"2017-12-11"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-11",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-12",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-13",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-14",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-15",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-16",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 47
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 1,
	 *                    "day": "2018-07-17",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 48
	 *                    },
	 *                    {
	 *                    "currentSchoolData": 0,
	 *                    "day": "2018-07-18",
	 *                    "paySchoolData": 0,
	 *                    "totalSchoolData": 48
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getSchoolCountData", method = RequestMethod.POST)
	public Tip getSchoolCountData(@RequestBody QueryHotData queryHotData) {

		List<EveryDayCountVo> everyDayCountVoList = schoolService.getSchoolCountData(queryHotData);
		return SuccessTip.buildSuccess(everyDayCountVoList);
	}

	/**
	 * @api {POST} /school/getSchoolSmsData 获取短信使用情况统计数据（学校）
	 * @apiGroup school
	 * @apiName getSchoolSmsData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {String} monthSchoolSmsData 短信使用量
	 * @apiSuccess {String} day 日期
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11",
	 *                  "endTime":"2017-12-11"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "month": "2017-07",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-08",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-09",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-10",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-11",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-12",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-01",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-02",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-03",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-04",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-05",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-06",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-07",
	 *                    "monthSchoolSmsData": 2
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getSchoolSmsData", method = RequestMethod.POST)
	public Tip getSchoolSmsData(@RequestBody QuerySmsData querySmsData) {

		List<EveryMonthSmsCountVo> everyMothCountVoList = schoolService.getSchoolSmsCountData(querySmsData, false);
		return SuccessTip.buildSuccess(everyMothCountVoList);
	}

	/**
	 * @api {POST} /school/getAllSchoolSmsData 获取短信使用情况统计数据（员工查所有学校）
	 * @apiGroup school
	 * @apiName getAllSchoolSmsData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiParam {Long} schoolId 学校id
	 * @apiSuccess {String} monthSchoolSmsData 短信使用量
	 * @apiSuccess {String} month 日期
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11",
	 *                  "endTime":"2017-12-11"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": [
	 *                    {
	 *                    "month": "2017-07",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-08",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-09",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-10",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-11",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2017-12",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-01",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-02",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-03",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-04",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-05",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-06",
	 *                    "monthSchoolSmsData": 0
	 *                    },
	 *                    {
	 *                    "month": "2018-07",
	 *                    "monthSchoolSmsData": 2
	 *                    }
	 *                    ],
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getAllSchoolSmsData", method = RequestMethod.POST)
	public Tip getAllSchoolSmsData(@RequestBody QuerySmsData querySmsData) {

		List<EveryMonthSmsCountVo> everyMothCountVoList = schoolService.getSchoolSmsCountData(querySmsData, true);
		return SuccessTip.buildSuccess(everyMothCountVoList);
	}

	/**
	 * @api {POST} /school/getSchoolChargeSlotData 学校收费时段情况(默认10天，当天则24小时)
	 * @apiGroup school
	 * @apiName getSchoolChargeSlotData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {int} schoolChargePeople 缴费人数
	 * @apiSuccess {int} schoolChargeData 缴费金额
	 * @apiSuccess {String} time 天
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11",
	 *                  "endTime":"2017-12-11"
	 *                  }
	 */
	@Permission
	@RequestMapping(value = "/getSchoolChargeSlotData", method = RequestMethod.POST)
	public Tip getSchoolChargeSlotData(@RequestBody QuerySmsData querySmsData) {

		List<DayOrHourChargeCountVo> DayOrHourChargeCountVoList = schoolService.getSchoolChargeSlotData(querySmsData);
		return SuccessTip.buildSuccess(DayOrHourChargeCountVoList);
	}

	/**
	 * @api {POST} /school/getFlowCountData 获取流水统计数据
	 * @apiGroup school
	 * @apiName getFlowCountData
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiSuccess {String} currentFlow 当前流水
	 * @apiSuccess {String} everyDay 日期
	 * @apiSuccess {String} totalFlow 总流水
	 * @apiVersion 1.3.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "startTime": "2017-11-11",
	 *                  "endTime":"2017-12-11"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data":
	 *                    {
	 *                    "currentFlow": 165,
	 *                    "everyDay": "2017-12-01",
	 *                    "totalFlow": 197.03
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/getFlowCountData", method = RequestMethod.POST)
	public Tip getFlowCountData(@RequestBody QueryHotData queryHotData) {

		List<EveryFlowCountVo> everyFlowCountVoList = schoolService.getFlowCountData(queryHotData);
		return SuccessTip.buildSuccess(everyFlowCountVoList);
	}

	/**
	 * @api {POST} /school/seeSchoolInfo 查看学校信息
	 * @apiGroup school
	 * @apiName seeSchoolInfo
	 * @apiParam {long} schoolId 学校主键ID
	 * @apiSuccess {String} agentName 代理商名称
	 * @apiSuccess {int} studentContribution 学生缴费人数
	 * @apiSuccess {Long} giveCount 短信使用总量（新增）
	 * @apiSuccess {String} freeMonth 赠送月份（新增）（一月,二月,5月...）
	 * @apiSuccess {bigDecimal} flow 总流水
	 * @apiSuccess {bigDecimal} aliFlow 支付宝流水（新增）
	 * @apiSuccess {bigDecimal} weixinFlow 微信流水（新增）
	 * @apiSuccess {Date} createTime 开通时间
	 * @apiSuccess {String} schoolName 学校名称
	 * @apiSuccess {String} provinceName 省
	 * @apiSuccess {String} cityName 市
	 * @apiSuccess {String} districtName 区
	 * @apiSuccess {String} schoolContactPeople 联系人
	 * @apiSuccess {String} contactTel 联系方式
	 * @apiSuccess {String} subMchId 学校微信商户号ID
	 * @apiSuccess {String} alipayNumber 学校对公支付宝账号
	 * @apiSuccess {String} mailBox 学校对公邮箱
	 * @apiVersion 1.2.0
	 * @apiSuccess {Integer} versionNo 版本号
	 * @apiVersion 1.1.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "schoolId": 54
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "data": {
	 *                    "agentNamesVoList": [
	 *                    {
	 *                    "agentName": "test",
	 *                    "area": "吴中区",
	 *                    "city": "苏州市",
	 *                    "province": "江苏省"
	 *                    }
	 *                    ],
	 *                    "alipayPid": "2222411",
	 *                    "cityCode": "苏州市",
	 *                    "contactTel": "215415",
	 *                    "detailAddr": "222waw",
	 *                    "districtCode": "吴中区",
	 *                    "provinceCode": "江苏省",
	 *                    "schoolContactPeople": "string",
	 *                    "schoolName": "string",
	 *                    "schoolType": 1,
	 *                    "versionNo": 0
	 *                    },
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/seeSchoolInfo", method = RequestMethod.POST)
	public Tip seeSchoolInfo(@RequestBody QuerySeeSchoolInfo queryHotData) {

		return SuccessTip.buildSuccess(schoolService.seeSchoolInfo(queryHotData));
	}

	/**
	 * @api {POST} /school/editSchoolInfo 学校信息编辑
	 * @apiGroup school
	 * @apiName editSchoolInfo
	 * @apiParam {long} schoolId 学校主键ID
	 * @apiParam {String} subMchId 学校微信商户号ID
	 * @apiParam {int} versionNo 版本号
	 * @apiParam {String} detailAddr 详细地址
	 * @apiParam {String} schoolContactPeople 学校联系人
	 * @apiParam {String} mailBox 学校邮箱
	 * @apiParam {String} alipayNumber 学校对公支付宝账号
	 * @apiParam {String} alipayPid 支付宝PID
	 * @apiParam {String} belongAgentName 所属代理商
	 * @apiVersion 1.0.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "schoolId": 59,
	 *                  "subMchId": "15484641136",
	 *                  "versionNo": 0
	 *                  "detailAddr":ssg
	 *                  "schoolContactPeople": 45646
	 *                  "mailBox": 1564
	 *                  "alipayNumber":1648
	 *                  "alipayPid":464684
	 *                  "belongAgentName": 17
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/editSchoolInfo", method = RequestMethod.POST)
	public Tip editSchoolInfo(@RequestBody EditSchoolInfo editSchoolInfo) {

		schoolService.editSchoolInfo(editSchoolInfo);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /school/exportExcel 导出学校列表
	 * @apiGroup school
	 * @apiName exportExcel
	 * @apiParam {String} schoolName 学校名称
	 * @apiParam {String} schoolContactPeople 联系人
	 * @apiParam {String} contactTel 联系方式
	 * @apiParam {Date} startTime 开始时间
	 * @apiParam {Date} endTime 结束时间
	 * @apiParam {Long} agentId 当前用户ID
	 * @apiParam {String} belongAgentName 所属代理商名称
	 * @apiVersion 1.2.0
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/exportExcel", method = RequestMethod.GET)
	public void exportExcel(HttpServletResponse response,
			@RequestParam(value = "schoolName", required = false) String schoolName,
			@RequestParam(value = "schoolContactPeople", required = false) String schoolContactPeople,
			@RequestParam(value = "contactTel", required = false) String contactTel,
			@RequestParam(value = "startTime", required = false) Date startTime,
			@RequestParam(value = "endTime", required = false) Date endTime,
			@RequestParam(value = "agentId", required = false) Long agentId,
			@RequestParam(value = "belongAgentName", required = false) String belongAgentName) {

		QuerySchoolInfo querySchoolInfo = new QuerySchoolInfo();
		querySchoolInfo.setSchoolName(schoolName);
		querySchoolInfo.setSchoolContactPeople(schoolContactPeople);
		querySchoolInfo.setContactTel(contactTel);
		querySchoolInfo.setStartTime(startTime);
		querySchoolInfo.setEndTime(endTime);
		querySchoolInfo.setAgentId(agentId);
		querySchoolInfo.setBelongAgentName(belongAgentName);
		schoolService.exportExcel(response, querySchoolInfo);
	}

	/**
	 * @api {GET} /school/teacherList 学校所有老师
	 * @apiGroup school
	 * @apiName teacherList
	 * @apiVersion 1.3.0
	 */
	@Permission
	@RequestMapping(value = "/teacherList", method = RequestMethod.GET)
	public Tip teacherList() {

		List list = schoolService.listSchoolTeacher();
		return SuccessTip.buildSuccess(list);
	}

	/**
	 * @api {POST} /school/addSchoolPayItem 增加或者修改学校收费项
	 * @apiGroup school
	 * @apiName addSchoolPayItem
	 * @apiParam {int} id ID
	 * @apiParam {String} name 收费项名称
	 * @apiParam {float} money 金额
	 * @apiParam {String} remark 备注
	 * @apiParam {int} versionNo 版本号
	 * @apiParam {int} flag 0非必选，1必选，2退费
	 * @apiVersion 1.4.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "name": "string",
	 *                  "money": "string",
	 *                  "remark": "string"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/addSchoolPayItem", method = RequestMethod.POST)
	public Tip addSchoolPayItem(@RequestBody @Valid AddSchoolPayItem addSchoolPayItem) {

		schoolService.addSchoolPayItem(addSchoolPayItem, 0);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {POST} /school/deleteSchoolPayItem 删除学校收费项
	 * @apiGroup school
	 * @apiName deleteSchoolPayItem
	 * @apiParam {int} id ID
	 * @apiParam {int} versionNo 版本号
	 * @apiVersion 1.4.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "id": "string",
	 *                  "versionNo": "string"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/deleteSchoolPayItem", method = RequestMethod.POST)
	public Tip deleteSchoolPayItem(@RequestBody AddSchoolPayItem addSchoolPayItem) {

		schoolService.addSchoolPayItem(addSchoolPayItem, 1);
		return SuccessTip.buildSuccess();
	}

	/**
	 * @api {GET} /school/listSchoolPayItem 学校收费项列表
	 * @apiGroup school
	 * @apiName listSchoolPayItem
	 * @apiVersion 1.4.0
	 * @apiParamExample {json} Request-Example:
	 *                  {
	 *                  "id": "string",
	 *                  "versionNo": "string"
	 *                  }
	 * @apiSuccessExample {json} Success-Response:
	 *                    {
	 *                    "code": 200,
	 *                    "message": "成功"
	 *                    }
	 */
	@Permission
	@RequestMapping(value = "/listSchoolPayItem", method = RequestMethod.GET)
	public Tip listSchoolPayItem() {

		return SuccessTip.buildSuccess(schoolService.listSchoolPayItem());
	}

	@InitBinder
	protected void initBinder(WebDataBinder binder) {

		binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), true));
	}
}
